import { defineStore } from 'pinia'
import { getHoseList } from '@/services'
const homeStore = defineStore('home', {
  state: () => ({
    houseList: [],
    currentPage: 1,
    isHashHouseList: true
  }),
  actions: {
    async fetchHoseList() {
      try {
        const res = await getHoseList(this.currentPage)
        if (res?.data.length > 0) {
          this.houseList.push(...res.data)
          this.currentPage++
        } else {
          this.isHashHouseList = false
        }
      } catch (err) {
        this.isHashHouseList = false
      }
    }
  }
})
export default homeStore
